﻿package mortal.game.view.ThanksGiving.panel
{
    import Message.Public.*;
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.rebate.item.*;
    import mortal.mvc.core.*;

    public class ThanksGivingTanBaoPanel extends GSprite
    {
        protected var _mbg:GImageBitmap;
        protected var _timeDes:GTextFiled;
        protected var _list1:CellsGridSprite;
        protected var _list2:CellsGridSprite;
        protected var _gotoTanBaoBtn:GLoadingButton;

        public function ThanksGivingTanBaoPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.ThanksGivingTanBaoBg, 0, 0, this);
            this._timeDes = UIFactory.gTextField("2015", 109, 183, 460, 25, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._list1 = UIFactory.getUICompoment(CellsGridSprite);
            this._list1.colNum = 1;
            this._list1.vCellWid = 100;
            this._list1.hCellWid = 72;
            this._list1.genCellFun = this.genItem;
            this._list1.genCells(3);
            this._list1.x = 53;
            this._list1.y = 290;
            this.addChild(this._list1);
            this._list2 = UIFactory.getUICompoment(CellsGridSprite);
            this._list2.colNum = 1;
            this._list2.vCellWid = 100;
            this._list2.hCellWid = 72;
            this._list2.genCellFun = this.genItem;
            this._list2.genCells(3);
            this._list2.x = 542;
            this._list2.y = 290;
            this.addChild(this._list2);
            this._gotoTanBaoBtn = UIFactory.gLoadingButton(ImagesConst.ThanksGivingTanBaoBtn_upSkin, 280, 466, 141, 42, this);
            this._gotoTanBaoBtn.label = "";
            this._gotoTanBaoBtn.configEventListener(MouseEvent.CLICK, this.onOpenTanBao);
            this.updateRuleAndTime();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._mbg = null;
            this._timeDes = null;
            this._list1 = null;
            this._list2 = null;
            this._gotoTanBaoBtn = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function genItem() : RebateItem
        {
            var _loc_1:* = UIFactory.getUICompoment(RebateItem);
            return _loc_1;
        }// end function

        private function updateRuleAndTime() : void
        {
            var _loc_1:int = 0;
            var _loc_2:Array = null;
            var _loc_3:RebateItem = null;
            var _loc_4:SPlayerItem = null;
            this._timeDes.text = ThanksGivingUtil.getOpenTimeStr(71375);
            _loc_2 = ThanksGivingUtil.tanBaoGiftCodeArr1;
            this._list1.genCells(_loc_2.length);
            _loc_1 = 0;
            while (_loc_1 < _loc_2.length)
            {
                
                _loc_3 = this._list1.cellArr[_loc_1];
                if (_loc_3)
                {
                    _loc_4 = new SPlayerItem();
                    _loc_4.itemCode = _loc_2[_loc_1];
                    _loc_3.updateInfo(_loc_4);
                }
                _loc_1++;
            }
            _loc_2 = ThanksGivingUtil.tanBaoGiftCodeArr2;
            this._list2.genCells(_loc_2.length);
            _loc_1 = 0;
            while (_loc_1 < _loc_2.length)
            {
                
                _loc_3 = this._list2.cellArr[_loc_1];
                if (_loc_3)
                {
                    _loc_4 = new SPlayerItem();
                    _loc_4.itemCode = _loc_2[_loc_1];
                    _loc_3.updateInfo(_loc_4);
                }
                _loc_1++;
            }
            return;
        }// end function

        private function onOpenTanBao(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawShow));
            return;
        }// end function

    }
}
